from django.db import models
from django.contrib.auth.models import User
from datetime import datetime
from django.core.files.storage import FileSystemStorage
from minicurso import settings

class Pessoa(models.Model):
    usuario = models.OneToOneField(User)
    imagem = models.FileField(storage=FileSystemStorage(location=settings.MEDIA_ROOT), upload_to='imagens', default='logos/no_image.gif',null=True,blank=True)
    segue = models.ManyToManyField("self", symmetrical = False, null = True, blank = True)
    #bloqueados = models.ManyToManyField("self", symmetrical = False, related_name = "Bloqueados")
    def __unicode__(self):
        return self.usuario.first_name

class Pergunta(models.Model):
    class Meta:
        ordering = ("-data",)
    enunciado = models.CharField(max_length = 200)
    resposta = models.TextField(null = True)
    data = models.DateTimeField(default=datetime.now,blank=True)
    from_pessoa = models.ForeignKey(Pessoa, related_name="pergunta_from", null = True)
    to_pessoa = models.ForeignKey(Pessoa,related_name="pergunta_to")
    def __unicode__(self):
        return self.enunciado

"""class Seguir(models.Model):
    from_pessoa = models.ForeignKey(Pessoa, related_name = "seguidor")
    to_pessoa = models.ForeignKey(Pessoa,related_name = "seguido")
    data = models.DateTimeField(default = datetime.now(), blank = True)"""
